<template>
  <div class="store">
    <div class="LoveMeal-search">
      <van-icon class="arrow-left" name="arrow-left" @click="$router.push({ name: 'my' })" />
      <van-search v-model="searchValue" shape="round" placeholder="请输入搜索关键词" @input="getSearch" @clear="searchValue = ''" />
    </div>
    <div class="instro">
      <div class="shopimg">
        <van-image :src="`${resourceURL}${obj.imagesurl}`" fit="cover" />
      </div>
      <div class="text">
        <div class="name">{{obj.shop_name}}</div>
        <div class="lebel">
          <div class="crownimg">
            <van-image :src="require('../../assets/img/store/crown.png')" fit="cover" />
          </div>
          <span>品牌自营</span>
        </div>
      </div>
    </div>
    <van-tabs>
      <van-tab title="全部商品"></van-tab>

    </van-tabs>
    <!-- <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white" loop>
      <van-swipe-item v-for="(item,index) in obj_banner" :key="index">
        <div class="swiper">
          <van-image :src="`${resourceURL}${item.pic_url}`" fit="cover" />
        </div>
      </van-swipe-item>
    </van-swipe> -->
    <van-list v-model="loading" :finished="finished" @load="onLoad" :error.sync="err" error-text="加载失败，点击这里重试">
      <rowsList :list="list" class="rowsList" />
    </van-list>
  </div>
</template>
<script>
import rowsList from "../../components/rowsList.vue";
export default {
  components: { rowsList },
  data () {
    return {
      id: this.$route.query.id || 0,
      obj: {},
      finished: false,
      loading: false,
      obj_banner: [],
      list: [],
      searchValue: "",
      page: "",
      err: false
    }
  },
  created () {
    this.shopinfo()
    //this.productlist()
  },
  methods: {
    // 获取店铺详情
    shopinfo () {
      this.$axios.get(this.$api.shopinfo, {
        params: {
          shop_id: this.id,

        }
      }).then((res) => {

        if (res.data.code == 1) {
          this.obj = res.data.data

        }
      })
    },
    onLoad () {
      this.page++
      this.productlist()

    },
    // 获取店铺商品列表
    productlist () {
      this.loading = true
      this.$axios.get(this.$api.productlist, {
        params: {
          shop_id: this.$route.query.id,
          name: this.searchValue,
          page: this.page,
          limit: '10',
          is_page: '2'
        }
      }).then((res) => {
        this.loading = false

        if (res.data.code == 1) {
          if (res.data.data.length == 0) {
            this.finished = true
          } else {
            this.list = this.list.concat(res.data.data);
            this.finished = false
          }
        } else {
          this.err = true
          this.finished = true
        }
      })
    },
    //获取搜索结果
    getSearch () {
      this.page = 1;
      this.list = [];
      this.productlist()

    },
  }
};
</script>
<style lang='less' scoped>
.store {
  min-height: 100vh;
  padding-bottom: 50px;
  background: #fff;
}
.van-tabs {
  /deep/.van-tab--active {
    font-weight: bold;
    color: #ff7733;
  }
  /deep/.van-tab__text {
    font-size: 14px;
  }
  /deep/.van-tabs__line {
    bottom: 22px;
    background: #ff7733;
  }
}
.van-tabs {
  width: 100px;
}
.instro {
  display: flex;
  width: 343px;
  margin-top: 10.5px;
  margin-left: 20px;
  .text {
    flex: 1;
    margin-left: 12px;
    .name {
      font-size: 16px;
      font-family: Microsoft YaHei-Bold, Microsoft YaHei;
      font-weight: bold;
      color: #06021a;
      text-overflow: -o-ellipsis-lastline;
      overflow: hidden; //溢出内容隐藏
      text-overflow: ellipsis; //文本溢出部分用省略号表示
      display: -webkit-box; //特别显示模式
      -webkit-line-clamp: 2; //行数
      line-clamp: 2;
      -webkit-box-orient: vertical; //盒子中内容竖直排列
    }
    .lebel {
      width: 69px;
      height: 18px;
      text-align: center;

      font-size: 12px;
      font-family: Microsoft YaHei;
      display: flex;
      color: #b60102;
      margin-top: 9px;

      .crownimg {
        /deep/.van-image {
          width: 13px;
          height: 11px;
        }
      }
    }
  }
}

.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed;
  width: 343px;
}
.my-swipe {
  width: 343px;
  height: 90px;
  border-radius: 10px;
  margin-top: 16px;
}
.swiper {
  width: 343px;
  height: 90px;
  .van-image {
    width: 343px;
    height: 90px;
    border-radius: 10px;
    overflow: hidden;
  }
}
.shopimg {
  .van-image {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
  }
}
.rowsList {
  margin-top: 15px;
}
.LoveMeal-search {
  display: flex;
  align-items: center;
  width: 100%;
  height: 70px;
  padding: 16px 8px 0 16px;
  background-color: #fff;
  box-sizing: border-box;
  .arrow-left {
    margin-right: 12px;
  }
  .van-search {
    flex: 1;
    .van-search__content {
      border: 1px solid #f2f2f2;
      border-radius: 6px;
      background-color: #fff;
    }
  }
}
</style>